import request from "@/utils/request";
import { loginFormData, loginResponseData, userInfoReponseData, UserListResponse, R,UserResp } from "./type";
import { User} from '@/views/acl/user/ts/user/type'


enum API {
    LOGIN_URL = "/auth/login",
    USERINFO_URL ="/user/info",
    LOGOUT_URL = "/auth/logout",
    USERS_URL = "/user/users",
    USER_ADD_URL = "/user/add",
    USER_UPDATE_URL = "/user/update",
    USER_DEL_URL = "/user/delete",
    USER_ONE_URL = "/user/one",
   
 }
 
//登录接口
// export const reqLogin = (data: loginFormData) => request.post<any, loginResponseData>(API.LOGIN_URL, data);
export const reqLogin = (data: loginFormData) => request.postForm<any, loginResponseData>(API.LOGIN_URL, data);
//获取用户信息
export const reqUserInfo = () => request.get<any, userInfoReponseData>(API.USERINFO_URL);
//退出登录
export const reqLogout = () => request.post<any, any>(API.LOGOUT_URL)

//获取用户分页数据
export const reqUsers = (data: any) => request.post<any, UserListResponse>(API.USERS_URL, data)

//新增用户
export const reqUserAdd = (data: User) => request.post<any, R<boolean>>(API.USER_ADD_URL, data)

//编辑用户
export const reqUserUpdate = (data: User) => request.post<any, R<boolean>>(API.USER_UPDATE_URL, data)

//删除用户
export const reqUserDel = (id: number) => request.delete<any, R<boolean>>(API.USER_DEL_URL + `?id=` + id)

//查询单个用户
export const requserOne = (id: number) => request.get<any, R<UserResp>>(API.USER_ONE_URL + `?id=` + id)

